import { Module } from "@nestjs/common";
import { UserService } from "./user.service";
import { UserController } from "./user.controller";
import { TypeOrmModule } from "@nestjs/typeorm";
import { User } from "@/modules/user/entities/user.entity";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { JwtModule } from "@nestjs/jwt";
import { BaseController } from "@/modules/user/base.controller";
import { Role } from "@/modules/role/entities/role.entity";
import { Menu } from "@/modules/menu/entities/menu.entity";
import { UserRole } from "../user-role/entities/user-role.entity";
import { RoleMenu } from "@/modules/role-menu/entities/role-menu.entity";
import { Log } from "@/modules/log/entities/log.entity";
import { UserSubuser } from "@/modules/user-subuser/entities/user-subuser.entity";

@Module({
    imports: [
        TypeOrmModule.forFeature([User, Role, UserRole, Menu, RoleMenu, Log, UserSubuser]),
        JwtModule.registerAsync({
            imports: [ConfigModule],
            useFactory: async (config: ConfigService) => ({
                secret: config.get("SECRET"),
                signOptions: {
                    expiresIn: config.get("JWT_EXPIRESIN")
                }
            }),
            inject: [ConfigService]
        })
    ],
    controllers: [BaseController, UserController],
    providers: [UserService],
    exports: [UserService]
})
export class UserModule {
}
